package de.hska.reka.websockets;

import org.springframework.stereotype.Component;
import org.xlightweb.server.HttpServer;

@Component
public class WebSocketServerServiceExporter extends AbstractServiceExporter {

	public void afterPropertiesSet() throws Exception {
		this.webSocketRawHandler
				.setControllerMethodMapPrototype(this.controllerMethodMap);
		this.webSocketRawHandler
				.setInvocationHandler(this.oneToManyInvocationHandler);
	}

	@Override
	public void initialized() {
		HttpServer httpServer;
		try {
			httpServer = new HttpServer(this.getPort(), this.webSocketRawHandler);
			httpServer.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
